package psi.services;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Record;

import psi.common.PSIException;
import psi.common.Result;

/**
 * 所有Service的基类
 * 
 * @author 李静波
 *
 */
public class PSIBaseService {
	/**
	 * 当前环境是否是演示环境
	 * 
	 * @return true：演示环境
	 */
	protected boolean isDemo() {
		String demo = System.getenv("IS_DEMO");
		return demo != null && demo.equals("1");
	}

	protected Result todo() {
		return new Result(false, "功能还没有开发");
	}

	protected Result ok() {
		return new Result(true, null, null);
	}

	protected Result ok(String id) {
		return new Result(true, null, id);
	}
	
	protected void bad(String msg) {
		throw new PSIException(msg);
	}
	
	protected List<Record> emptyList() {
		return new ArrayList<Record>();
	}
}
